<!-- 我的粉丝 -->
<template>
	<view class="page">
		
		<view class="menuList" v-if='commission.length>0'>
			<view class="nav_top_box" :style="{top:0}">
				<view class="navlists" :style="{'--color': color}" 
				v-if="commission.length>0" 
				:class="navTab==1?'navAction thmeColor':''" 
				@click="navclick(1,0)">
				<text>{{level_name[0].name}}（{{commission[0]?commission[0].length:0}}）</text>
			</view>
				<view class="navlists" 
				:style="{'--color': color}" 
				v-if="commission.length>1" 
				:class="navTab==2?'navAction thmeColor':''" 
				@click="navclick(2,1)">
				<text>{{level_name[1].name}}（{{commission[1]?commission[1].length:0}}）</text>
			</view>
				<view class="navlists" 
				:style="{'--color': color}" 
				v-if="commission.length>2" 
				:class="navTab==3?'navAction thmeColor':''" 
				@click="navclick(3,2)">
				<text>{{level_name[2].name}}（{{commission[2]?commission[2].length:0}}）</text>
			</view>
				<view class="Advertising_article thmeBg thmeColor" :style="{'--color': color, left: 33*(navTab - 1) + '%'}"></view>
			</view>
		</view>
		<view class="type2" v-if='list && list.length > 0'>
			<view class="item flex-box" v-for="(item,index) in list" :key="index">
				<image class="friHead" @error="item.v_headimg = ''" :src="item.v_headimg?item.v_headimg:staticUrl+'/images/jh_up/head.jpg'" mode=""></image>
				<view class="flex">
					<view>
						<text class="name">{{item.v_name}}</text>
						<text class="id">（{{item.v_tel}}）</text>
					</view>
					<view class="time">{{item.v_addtime}}</view>
					<view class="num-list flex-box">
						<view class="num">自购：{{item.orders}}</view>
						<view class="num">粉丝数：{{item.members}}</view>
						<view class="num">单量：{{item.orders_num}}</view>
						<view class="num">业绩：{{item.cumulative_income}}</view>
					</view>
				</view>
			</view>
		</view>
		<emptys v-else  :title='"你还没有该信息内容哟~"'></emptys>
	</view>
</template>

<script>
	import {mapState} from 'vuex';
	var that;
	export default {
		data() {
			return {
				title:'',
				navTab: 1,
				staticUrl: this.staticUrl,
				toTop: false,
				brokerage_list: [],
				noData: false,
				
				commission: [],
				list: '',
				msg: '一',
				
				state:'', // 我的团队
				level_name:[],
			}
		},
	
		onShow() {
			if(this.state == 1){
				this.my_income_team();
			}else{
				this.my_income();
			}
			
		},
		computed:{
			...mapState(['tabTitle','color','city','navHeight','System','share','vid']),
		},
		onLoad(e) {
			console.log(e);
		  let that = this;
		  if(e.state == 1){
			  that.title = "我的团队";
			  that.state = e.state;
		  }
		
		},
		methods: {
			navclick(i, positions){
				let that = this;
				if(positions == 0){
					that.msg = '一'
				}
				if(positions == 1){
					that.msg = '二'
				}
				if(positions == 2){
					that.msg = '三'
				}
				that.list = that.commission[positions]
				that.navTab = i;
			},
			
		   //  我的会员
			my_income(){
				let that = this;
				that.$http.post({
					url: '/zzj_singleSaleApi/distribution_people',
				
				}).then(res => {
					that.commission = res.data;
					that.level_name = res.level_name;
					if(res.data[0]){
						that.list = res.data[0]
					}
				}) 
			},
			
			//  我的团队
			my_income_team(){
				let that = this;
				that.$http.post({
					url: '/zzj_singleSaleApi/distribution_people_team',
				}).then(res => {
					if(res.errcode == "100"){
						that.commission = res.data;
						if(res.data[0]){
							that.list = res.data[0]
						}
					}else{
						uni.showToast({
							title:res.msg,
							icon:"none"
						})
					}
					
				}) 
			},
		}
	}
</script>

<style scoped lang="scss">
	.right{
		float: right;
	}
	.page{
		background-color: #F8F8F8;
		.nav_top_box{
			width: 100%;
			height: 80upx;
			background: #FFFFFF;
			line-height: 80upx;
			font-size: 28upx;
			color: #333333;
			position: fixed;
			top: 0;left: 0;right: 0;
			z-index: 99;
			box-shadow: 0 0 5px 0px rgba(0,0,0,.1);
			.navlists{
				width: 33%;
				display: inline-block;
				text-align: center;
				color: #999999;
				font-size: 24upx;
				&.navAction{
					position: relative;
					font-weight: bold;
					font-size: 40upx;
					color: #222222;
				}
			}
			.Advertising_article{
				width: 30upx;
				height: 6upx;
				position: absolute;
				bottom: 0;
				transition: left .2s;
				border-radius: 6upx;
				background-color: #222222;
				transform: translateX(106rpx);
			}
		}
		
		// 样式二
		.type2{
			padding: 20rpx;
			padding-top: 100upx;
			.item{
				background-color: #FFFFFF;
				padding: 20rpx;
				border-radius: 8rpx;
				margin-bottom: 20rpx;
				.friHead{
					border-radius: 50%;
					height: 64rpx;
					width: 64rpx;
					margin-right:20rpx;
				}
				.name{
					font-size: 28rpx;
					font-weight: bold;
				}
				.id{
					font-size: 28rpx;
					color: #999999;
				}
				.time{
					color: #999999;
					margin-top: 4rpx;
				}
				.num-list{
					flex-wrap: wrap;
					padding: 20rpx;
					padding-bottom: 0;
					margin-top: 20rpx;
					background-color: #F5F5F5;
					border-radius: 8rpx;
					.num{
						width: 50%;
						margin-bottom: 20rpx;
						color: #333333;
						font-size: 26rpx;
					}
				}
			}
		}
	}
</style>
